package com.qf.android.huihui.common;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.View;

import com.handmark.pulltorefresh.library.PullToRefreshBase;
import com.qf.android.huihui.R;


/**
 * Created by 韩爽 on 2017/1/6.
 */

public class InfoRecyclerView extends PullToRefreshBase<RecyclerView> {
    public int sroll=0;
    public InfoRecyclerView(Context context) {
        super(context);
    }

    public InfoRecyclerView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    public Orientation getPullToRefreshScrollDirection() {
        return Orientation.VERTICAL;
    }

    @Override
    protected RecyclerView createRefreshableView(Context context, AttributeSet attrs) {
        RecyclerView rv=new RecyclerView(context,attrs);
        rv.setNestedScrollingEnabled(false);
        rv.setId(R.id.info_rv);
        return rv;
    }

    @Override
    protected boolean isReadyForPullEnd() {
        View view = getRefreshableView().getChildAt(getRefreshableView().getChildCount() - 1);
        if (null != view) {
            if(getRefreshableView().getBottom() >= view.getBottom()){
                sroll=getRefreshableView().getBottom() - view.getBottom();
                return true;
            }
            else
                return false;

        }
        return false;
    }

    @Override
    protected boolean isReadyForPullStart() {
        View view = getRefreshableView().getChildAt(0);

        if (view != null) {



                 return view.getTop() >= getRefreshableView().getTop();

        }
        return false;
    }

}
